package com.hkemmm.control;

import com.hkemmm.bean.UserInfo;
import com.hkemmm.model.UserModel;
import com.hkemmm.utils.MyUtils;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.util.List;

@WebServlet(name = "UserInfoQueryServlet", value = "/UserInfoQueryServlet")
public class UserInfoQueryServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String userName = request.getParameter("userName");
        String userTel = request.getParameter("userTel");

        String userRegisteDate1 = request.getParameter("userRegisteDate1");
        String userRegisteDate2 = request.getParameter("userRegisteDate2");

        UserInfo userInfo = MyUtils.getInstence(UserInfo.class);
        userInfo.setUserName(userName);
        userInfo.setUserRegisteDate(MyUtils.coverStrToDate(userRegisteDate1,"yyyy-MM-dd"));
        userInfo.setUserRegisteDate2(MyUtils.coverStrToDate(userRegisteDate2,"yyyy-MM-dd"));

        List<UserInfo> lstUsers = MyUtils.getInstence(UserModel.class).queryUserInfoByParams(userInfo);

        request.getSession().setAttribute("lstUsers",lstUsers);

        request.getRequestDispatcher("WEB-INF/viewpages/userInfoQueryDetail.jsp").forward(request,response);

    }
}
